﻿using System;
using System.Collections.Generic;
using Core.Model;

namespace UI.Models.Catalog
{
    public class ProductsPerCategoryViewModelfactory
    {
        public ProductsPerCategoryViewModel CreateFrom(List<Product> products, Core.Model.Category category)
        {
            if (products == null) throw new ArgumentNullException("products");
            if (category == null) throw new ArgumentNullException("category");
            var model = new ProductsPerCategoryViewModel {CategoryName = category.Name};
            foreach (Product product in products)
            {
                model.Products.Add(new ProductListViewModel {Name = product.Name, ProductId = product.ProductId});
            }
            return model;
        }
    }
}